package com.ruoyi.project.drug.controller;


import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.drug.domain.DrugInbound;
import com.ruoyi.project.drug.service.DrugInboundcheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/drug/inboundcheck")
public class DrugInboundcheckController extends BaseController {
    @Autowired
    private DrugInboundcheckService drugInboundcheckService;

    //查询
    @GetMapping("/list")
    @PreAuthorize("@ss.hasAnyPermi('drug:inboundcheck:list')")
    public TableDataInfo list(DrugInbound drugInbound){
        startPage();
        List<DrugInbound> list= drugInboundcheckService.selectDrugInbound(drugInbound);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('drug:inbound:edit')")
    @Log(title = "采购管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody DrugInbound drugInbound)
    {
        drugInbound.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(drugInboundcheckService.updateDrugInboundStatus(drugInbound));
    }

}
